<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateSystemErrorCode extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('system_project_module_error', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger("projectId")->default(0)->comment("项目Id");
            $table->unsignedBigInteger("fullCode")->default(0)->comment("完整错误码");
            $table->string("moduleId")->default("")->comment("模块id");
            $table->string("errorKey")->default("")->comment("错误码对应key");
            $table->string("errorCode")->default("")->comment("错误码Code");
            $table->string("errorEnDesc")->default("")->comment("错误码对应英文描述");
            $table->string("errorCnDesc")->default("")->comment("错误码对应中文描述");


            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedInteger('isDeleted')->default(0)->comment('是否删除 0 - 正常 1 - 已删除');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '系统项目模块错误码对照表';

            $table->unique(["fullCode"], "idx_fullCode");
            $table->unique(["projectId", "moduleId", "errorKey"], "idx_projectId_moduleId_errorKey");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('system_project_module_error');
    }
}
